<template>
	<view class="page">
		<view class="nav_bar" style="background-color: rgba(255, 255, 255, 1);">
			<uni-nav-bar color="#333" left-icon="left" title="订单详情" :border='false' :fixed="true"
				background-color="transparent" @clickLeft="$native.backAction()"></uni-nav-bar>
		</view>

		<view class="nav_box"></view>

		<view class="storeName flex_center" @click="$native.toStore(order.store_id)">
			<text>{{order.store_name || ''}}</text>
			<u-icon name="arrow-right" color="#CCCCCC" size="16"></u-icon>
		</view>

		<view class="product flex_center"
			@click="$util.toUrl(`/pages/create/product?goods_id=${order.goods_id}&from_web=1&provider_id=${order.kefu == 1 ? order.provider_id : 0}`)">
			<image v-if="order.goods_image" :src="order.goods_image[0]" mode="aspectFill"></image>
			<view class="name hidden">
				<text>{{order.name || ''}}</text>
				<view>
					<i>￥</i>{{ order.price }}
				</view>
			</view>
		</view>

		<view class="order_content_text flex_r_between" v-if="order.status != 1">
			<text>实付款</text>
			<view class="price">
				<view><i>￥</i>{{order.pay_price || '0'}}</view>
			</view>
		</view>

		<view class="line"></view>

		<view class="order_content_text flex_r_between">
			<text>下单时间：</text>
			<view class="hidden">
				<uni-dateformat :date="order.create_time" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>付款时间：</text>
			<view class="hidden" v-if="order.pay_time">
				<uni-dateformat :date="order.pay_time" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
			</view>
			<view class="hidden" v-else>
				-
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>订单编号：</text>
			<view class="hidden">
				{{order.order_sn || '-'}}
			</view>
		</view>

		<button @click="toSubmit">
			确认
		</button>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				order: {},
			}
		},
		methods: {
			getDetail() {
				this.$get('/order/getOrderInfo', {
					order_id: this.order_id
				}).then(res => {
					this.order = res.data;
				})
			},

			toSubmit() {
				this.$get('/order/finishOrder', {
					order_id: this.order_id
				}).then(res => {
					this.$util.msg(res.msg);
					this.$native.backAction();
				});
			},

		},
		onLoad(option) {

			if (option.token) {
				uni.setStorageSync('token', option.token);
				uni.setStorageSync('cid', option.cid);
				uni.setStorageSync('terminal', option.terminal);
			}

			if (option.order_id) {
				this.order_id = option.order_id;
				this.getDetail()
			}
		},
	}
</script>

<style lang="less" scoped>
	.page {
		padding: 32rpx 32rpx 168rpx;
		min-height: 100vh;
		background: #FFFFFF;
	}

	// 商品
	.product {
		margin-top: 32rpx;

		image {
			width: 128rpx;
			height: 128rpx;
			border-radius: 16rpx;
			color: #ECECF4;
			margin-right: 20rpx;
		}

		.name {
			flex: 1;

			text {
				font-weight: 500;
				font-size: 32rpx;
				color: #131313;
			}

			view {
				i {
					font-size: 24rpx;
					font-style: normal;
				}

				font-weight: 600;
				font-size: 32rpx;
				color: #131313;
			}
		}

	}

	// 商品详情标签
	.line {
		height: 2rpx;
		background: #EEEEEE;
		margin-top: 32rpx;
	}

	.order_content_text {
		margin-top: 32rpx;

		text {
			font-size: 28rpx;
			color: #131313;
			width: 240rpx;
		}

		.price {
			font-weight: 600;
			font-size: 40rpx;
			color: #FD2A53;

			i {
				font-style: normal;
				font-size: 28rpx;
			}
		}

		.kefu {
			font-size: 28rpx;
			color: #999999;
		}

		view {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #999999;

			text {
				font-size: 28rpx;
				color: #999999;
			}
		}
	}

	button {
		width: 560rpx;
		height: 96rpx;
		background: #FD2A53;
		border-radius: 50rpx;
		font-weight: 500;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 96rpx;
		position: fixed;
		bottom: 30rpx;
		left: 50%;
		transform: translateX(-50%);
	}
</style>